package com.zhhs.jzcd.record.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhhs.framework.aspectj.lang.annotation.Log;
import com.zhhs.framework.aspectj.lang.enums.BusinessType;
import com.zhhs.jzcd.record.domain.BaseSendRecord;
import com.zhhs.jzcd.record.service.IBaseSendRecordService;
import com.zhhs.framework.web.controller.BaseController;
import com.zhhs.framework.web.domain.AjaxResult;
import com.zhhs.common.utils.poi.ExcelUtil;
import com.zhhs.framework.web.page.TableDataInfo;

/**
 * 精准营销发送记录Controller
 *
 * @author ruoyi
 * @date 2023-08-04
 */
@RestController
@RequestMapping("/jzcd/record")
public class BaseSendRecordController extends BaseController
{
    @Autowired
    private IBaseSendRecordService baseSendRecordService;

    /**
     * 查询精准营销发送记录列表
     */
    @PreAuthorize("@ss.hasPermi('record:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseSendRecord baseSendRecord)
    {
        startPage();
        List<BaseSendRecord> list = baseSendRecordService.selectBaseSendRecordList(baseSendRecord);
        return getDataTable(list);
    }

    /**
     * 导出精准营销发送记录列表
     */
    @PreAuthorize("@ss.hasPermi('record:record:export')")
    @Log(title = "精准营销发送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseSendRecord baseSendRecord)
    {
        List<BaseSendRecord> list = baseSendRecordService.selectBaseSendRecordList(baseSendRecord);
        ExcelUtil<BaseSendRecord> util = new ExcelUtil<BaseSendRecord>(BaseSendRecord.class);
        util.exportExcel(response, list, "精准营销发送记录数据");
    }

    /**
     * 获取精准营销发送记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('record:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(baseSendRecordService.selectBaseSendRecordById(id));
    }

    /**
     * 新增精准营销发送记录
     */
    @PreAuthorize("@ss.hasPermi('record:record:add')")
    @Log(title = "精准营销发送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseSendRecord baseSendRecord)
    {
        return toAjax(baseSendRecordService.insertBaseSendRecord(baseSendRecord));
    }

    /**
     * 修改精准营销发送记录
     */
    @PreAuthorize("@ss.hasPermi('record:record:edit')")
    @Log(title = "精准营销发送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseSendRecord baseSendRecord)
    {
        return toAjax(baseSendRecordService.updateBaseSendRecord(baseSendRecord));
    }

    /**
     * 删除精准营销发送记录
     */
    @PreAuthorize("@ss.hasPermi('record:record:remove')")
    @Log(title = "精准营销发送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseSendRecordService.deleteBaseSendRecordByIds(ids));
    }
}
